package com.java.tutorials.jdk7.fileoperation;
import com.java.tutorials.Constants;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
/**
 * Created by xuzhike on 2016/1/25.
 * http://www.java2s.com/Code/Java/JDK-7/Readingallofthelinesofafilereturnedasalist.htm
 * Reading all of the lines of a file returned as a list
 */
public class ReadingAlOofLinesOfFileReturnedASalist {
    public static void main(String[] args) throws IOException {
        Path path = Paths.get(Constants.TEST_FILE_WITH_PATH);
        List<String> contents = Files.readAllLines(path, Charset.defaultCharset());
        for (String b : contents) {
            System.out.println(b);
        }

    }
}
